<?php

include_once("../modelo/conexion.php");
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Pais
 *
 * @author mortega
 */
class Pais {

    public function getId() {
        return $this->id;
    }

    public function setId($id) {
        $this->id = $id;
    }

    public function getNom_pais() {
        return $this->nom_pais;
    }

    public function setNom_pais($nom_pais) {
        $this->nom_pais = $nom_pais;
    }

    function sql_quote($valor) {
        if (get_magic_quotes_gpc()) {
            $valor = stripslashes($valor);
        }
        //comprueba si existe la función  
        if (function_exists("mysql_real_escape_string")) {
            $valor = mysql_real_escape_string($valor);
        }
        //para las versiones < 4.3.0 de php usamos addslashes  
        else {
            $valor = addslashes($valor);
        }
        return $valor;
    }

    function anti_inyection() {
        $this->id_pais = $this->sql_quote($this->id_pais);
        $this->nom_pais = $this->sql_quote($this->nom_pais);
    }

    function selectComboPais($con = null, $nom_combo) {
        if (empty($con)) {
            $con = new Conexion();
        }
        $sql = "select id_pais, nom_pais from paises order by id_pais";
        $result = $con->Ejecuto($sql, $con);
        return $result;
    }
    
    function selectComboPais2($con = null, $nom_combo) {
        if (empty($con)) {
            $con = new Conexion();
        }
        $sql = "select id_pais, nom_pais from paises order by id_pais";
        $result = $con->Ejecuto($sql, $con);
        $devuelvo = "<select name='" . $nom_combo . "' id='" . $nom_combo . "'>";
        if ($result) {
            while ($reg = mysql_fetch_array($result)) {
                $devuelvo .= "<option value =" . $reg['id_pais'] . ">" . $reg['nom_pais'] . "</option>";
            }
            $devuelvo .= "</select>";
        }
        return $devuelvo;
    }

}

?>
